package com.spa.infrastructure.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.spa.application.command.shop.ShopWithdrawApplyCommand;
import com.spa.application.command.shop.ShopWithdrawApplyNewCommand;
import com.spa.application.dto.PageResult;
import com.spa.application.dto.admin.ShopWithdrawExportDTO;
import com.spa.application.dto.admin.ShopWithdrawList4AdminDTO;
import com.spa.application.dto.shop.ShopWithdrawListDTO;
import com.spa.application.dto.shop.ShopWithdrawProgressDTO;
import com.spa.application.query.admin.ShopWithdrawListQuery;
import com.spa.application.query.shop.ShopWithdrawOrderListQuery;
import com.spa.application.query.shop.ShopWithdrawQuery;
import com.spa.application.query.shop.ShopWithdrawRecordDetailQuery;
import com.spa.domain.entity.ShopWithdrawRecord;
import com.spa.infrastructure.enums.withdraw.WithdrawStatusEnum;
import com.spa.infrastructure.repository.condition.OrderInfoCondition;
import com.spa.infrastructure.repository.condition.ShopWithdrawRecordCondition;
import com.spa.infrastructure.repository.po.ShopWithdrawRecordPO;
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper
@MapperConfig(unmappedTargetPolicy = ReportingPolicy.WARN)
public interface ShopWithdrawRecordMapperStruct {

    ShopWithdrawRecordMapperStruct INSTANCE = Mappers.getMapper(ShopWithdrawRecordMapperStruct.class);

    ShopWithdrawRecordPO command2Po(ShopWithdrawApplyCommand command);

    Page<ShopWithdrawRecord> po2Entity4Page(Page<ShopWithdrawRecordPO> page);
    List<ShopWithdrawRecord> po2Entity4List(List<ShopWithdrawRecordPO> list);

    ShopWithdrawRecord po2Entity(ShopWithdrawRecordPO po);

    PageResult<ShopWithdrawListDTO> entity2ShopWithdrawListDto4Page(Page<ShopWithdrawRecord> page);
    PageResult<ShopWithdrawList4AdminDTO> entity2ShopWithdrawList4AdminDto4Page(Page<ShopWithdrawRecord> page);

    ShopWithdrawRecordCondition query2Condition(ShopWithdrawQuery query);
    ShopWithdrawRecordCondition query2Condition(ShopWithdrawListQuery query);

    ShopWithdrawProgressDTO entity2ShopWithdrawProgressDto(ShopWithdrawRecord entity);

    List<ShopWithdrawExportDTO> entity2ShopWithdrawExportDto4List(List<ShopWithdrawRecord> list);

    @Mapping(source = "status",target = "status",qualifiedByName = "int2Str")
    ShopWithdrawExportDTO entity2ShopWithdrawExportDto(ShopWithdrawRecord entity);

    @Named(value = "int2Str")
    default String int2Str(Integer value) {
        return WithdrawStatusEnum.byCode(value).getDesc();
    }

    ShopWithdrawRecordPO commandShopWithdrawRecord2Po(ShopWithdrawApplyNewCommand command);

    OrderInfoCondition query2OrderInfoWithdrawCondition(ShopWithdrawOrderListQuery query);

    OrderInfoCondition query2ConditionWithdrawOrderListCondition(ShopWithdrawRecordDetailQuery query);
}
